#ifndef SPIDEVICE_H
#define	SPIDEVICE_H

#include "mytype.h"
#include "stdint.h"
#include "MKE06Z4.h"
#include "system_MKE06Z4.h"
#include "spi.h"

#ifdef	__cplusplus
extern "C" {
#endif	
	
#ifdef   _SPI_MODULE_
#define  SPI_EXT
#else
#define  SPI_EXT  extern
#endif

#define SPI_SS_ENABLE()    FGPIOB->PCOR = 0x08
#define SPI_SS_DISABLE()   FGPIOB->PSOR = 0x08

	typedef enum
	{
		SPI_IDLE = 0,
		SPI_BUSY
	} SPI_ST_Type;

	volatile SPI_EXT SPI_ST_Type SpiSt;

	void SpiInit(void);
	void SpiRead(uint8_t *Des,uint16_t Len);
	void SpiWrite(uint8_t *Src,uint16_t Len);
	void SpiRW(uint8_t *Des,uint8_t *Src,uint16_t Len);

	uint8_t SpiRWSignal(uint8_t Data);

#undef SPI_EXT

#ifdef	__cplusplus
}
#endif

#endif	/* SPIDEVICE_H */
